<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>缤格</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../script/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/binge.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/layui/layui.all.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body style="background: #f5f5f5; min-height: 100vh;">
<!-- header -->
<div id="header" style="height: 0.9rem; background: #fff; width: 100%; z-index: 99">
    <div class="header">
        <div class="head-back">
            <a href="javascript:void(0);" tapmode onclick="comeBack()" class="">取消</a>
        </div>
        <div class="head-title">
            <h6>评价一下</h6>
        </div>
        <div class="head-action">
            <a href="javascript:void(0);" tapmode onclick="getSubmit()" class="">提交</a>
        </div>
    </div>
</div>
<!-- header end -->

<div class="header-h" style="padding-top: 1.4rem; background: #fff;"></div>
<div class="evaluate-star">

    <div id="star"></div>

    <div class="note">请点击星星打个分吧~</div>

</div>

<div class="evaluate-text">
    <textarea name="" id="content" cols="30" rows="10" placeholder="我来说点什么~(选填)"></textarea>
</div>

<div class="evaluate-name">
    <p>匿名评价</p>
    <div class="radio-on"></div>
</div>



</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">

    var radioOn = false;//是否匿名
    var starNum = 0;
    var gc_id = '';
    apiready = function () {

        setFixStatusBar(); //设置状态栏
        keybackListener()
        gc_id = api.pageParam.id;
        // gc_id = 3;


    };

    $(".evaluate-name").on('click',function () {
        var _this = $(this);
        if(_this.hasClass('on')){
            _this.removeClass('on');
            radioOn = false;
        }else {
            _this.addClass('on');
            radioOn = true;
        }
    })

    layui.use(['rate'], function(){
        var rate = layui.rate;
        //只读
        rate.render({
            elem: '#star',
            value: 0,
            half: true, //开启半星
            choose: function (value) {
                starNum = value;
                console.log(starNum)
            }
        });

    });

    //提交评星
    function getSubmit(){
        if(starNum == 0){
          pop.notice('请先评星再提交');
          return;
        }
        var anonymous = 2;
        if(radioOn){
          anonymous = 1;
        }
        var param = {
            token: $api.getStorage('token'),
            gc_id: gc_id,//广场id
            aver_socre: starNum,//评星
            anonymous: anonymous,//是否匿名评论：1是匿名 2不是匿名
            content: $("#content").val(),//评论内容
        }
        pop.loading();
        getAjax(Interface.set_circle_px, param, function (res) {
           pop.notice(res.msg);
           api.sendEvent({
               name: 'star',
           });

           setTimeout(function(){
              comeBack();
           },2000)
           pop.close();
        },function(error){
           pop.close();
            pop.notice(error.msg);
        });

    }


</script>
